<?php
//管理员模型
namespace King\Model;
use Think\Model;

/**
 * 用户模型
 */
class memberModel extends Model{
    
    protected $tableName = 'member';

    /**
     * 自动完成
     * @var array
     */
    protected $_auto = array(
    );
    

    /*
     * 自动验证
     */
    protected $_validate = array(
     );
    
    /*
     * 获取列表
     */
    public function getMemberList($where,$page,$order='uid DESC'){
        $res = $this->where($where)->order($order)->page($page,25)->select();
        return $res;
    }
	
    /*
     * 获取列表,不分页
     */
    public function getMemberLists($where){
        $res = $this->where($where)->order('uid DESC')->select();
        return $res;
    }
    
    /*
     * 统计数量
     */
    public function getMemberCount($where){
        $res = $this->where($where)->count();
        return $res;
    }
    
    /*
     * 添加
     */
    public function addMember($data){
        $res = $this->add($data);
        return $res;
    }
    
    /*
     * 获取信息
     */
    public function getMember($where){
        $res = $this->where($where)->find();
        return $res;
    }
	
    /*
     * 编辑信息
     */
    public function editMember($where,$data){
        return $this->where($where)->save($data);
    }
    
    /*
     * 扣减金钱
     */
    public function kouQian($uid,$filed,$money){
        $res = $this->where(array("uid"=>$uid))->setDec($filed,$money);
        return $res;
    }
    
    /*
     * 加钱
     */
    public function jiaQian($uid,$filed,$money){
        $res = $this->where(array("uid"=>$uid))->setInc($filed,$money);
        return $res;
    }
    
    /*
     * 对指定币种进行求和
     */
    public function sumLeft($type){
        $res = $this->sum($type);
        return $res;
    }
    
}
